<template>
	<view class="content">
		<view class="flex mine_message">
			<ul >
				<li class="flex">
					<view class="message_left">
						头像
					</view>
					<view class="message_right">
						<image src="../../static/me1.png" mode=""></image>
					</view>
				</li>
				<li class="flex">
					<view class="message_left">
						手机号
					</view>
					<view class="message_right">
					<input type="number" placeholder="请输入手机号" maxlength="11" v-model="userPhone"/>
					
					</view>
				</li>
				<li class="flex">
					<view class="message_left">
						头像
					</view>
					<view class="message_right">
						<picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange">
							<view class="uni-input">{{date}}</view>
						</picker>
					</view>
				</li>
				<li class="flex">
					<view class="message_left">
						收货地址
					</view>
					<!-- <view class="message_right" @click="address()">
						修改/添加
					</view> -->
					<view class="message_right">
						修改/添加
					</view>
				</li>
			</ul>
		</view>
	</view>
</template>

<script>
	
		//出生日期
		function getDate(type) {
			const date = new Date();
		 
			let year = date.getFullYear();
			let month = date.getMonth() + 1;
			let day = date.getDate();
		 
			if (type === 'start') {
				year = year - 10;
			} else if (type === 'end') {
				year = year + 10;
			}
			month = month > 9 ? month : '0' + month;
			day = day > 9 ? day : '0' + day;
		 
			return `${year}-${month}-${day}`;
		}
	

	export default{
		data(){
			return{
				userPhone:'',
				date: getDate({
								format: true
							 }),
								startDate: getDate('start'),
								endDate: getDate('end'),
				}

			
		},
	
		methods:{
			//出生日期
				bindDateChange: function(e) {
						this.date = e.detail.value;
					},
					//跳转收货地址
					address:function(){
						uni.navigateTo({
							url:'./address'
						})
					}
				},
			 login(){
							let reg = /^[1][3,4,5,7,8,9][0-9]{9}$/
							if (!this.userPhone) {      //判断如果手机号为空，提示用户输入手机号
								uni.showToast({
									title: '请输入手机号',
									icon: 'none'
								})
								return
							} else if (!reg.test(this.userPhone)) {        //判断手机号格式时候正确
								uni.showToast({
									title: '请输入正确的手机号',
									icon: 'none'
								})
								return
							}
							
						}
		
	}
</script>

<style>
	.flex{display: flex;flex-direction: row;justify-content: space-between;flex-wrap: wrap;}
	.mine_message ul{width:100%;padding: 0rem 40rpx;}
	.mine_message ul li {height:60rpx;padding: 20rpx;border-bottom: 1px solid #ccc;}
	.message_left{width:43%}
	/* uio */
	.message_right image{display: block;width:80rpx;height: 80rpx;border-radius: 40rpx;}
</style>